import request from '@/utils/axios'

export function login(data) {
  return request({
    url: '/vue-admin-template/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: {token}
  })
};

export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
};

/**
 * 用户新增
 * @param param
 * @returns {*}
 */
export function insert(param) {
  return request({
    url: '/api/user/insert',
    method: 'post',
    data: param
  })
};

/**
 * 用户列表
 * @param param
 * @returns {*}
 */
export const userList = param => request({
  url: '/api/user',
  method: 'get',
  params: param
});

export const userPageList = param => request({
  url: '/api/user/findPage',
  method: 'post',
  data: param
});

/**
 * 逻辑删除用户
 * @param param
 */
export const deleteUserByUserId = (param = {}) => request({
  url: `/api/user/${param.userId}`,
  method: 'delete'
})

/**
 * 物理删除用户
 * @param param
 */
export const deleteUser = (param = {}) => request({
  url: `/api/user/delete/${param.userId}`,
  method: 'delete'
})

/**
 * 批量逻辑删除用户列表
 * @param param
 * @returns {AxiosPromise}
 */
export const deleteUserListApi = param => request({
  url: `/api/user/deleteList`,
  method: 'delete',
  data: param
})

/**
 * 批量物理删除用户列表
 * @param param
 */
export const deleteUserList = param => request({
  url: `/api/user/deleteUserList`,
  method: 'delete',
  data: param
})

// export const validateUserExistApi = (param, options = {}) => request({
//   url: `/api/user/exist`,
//   method: 'get',
//   params: param,
//   _meta: options
// })

/**
 * 根据用户名判断用户是否重复
 * @param param
 */
export const validateUserExistApi = param => request({
  url: '/api/user/exist',
  method: 'get',
  params: param
});

/**
 * 新增用户
 * @param param
 */
export const insertUserApi = param => request({
  url: '/api/user',
  method: 'post',
  data: param
})

/**
 * 修改用户
 * @param param
 */
export const updateUserApi = param => request({
  url: '/api/user',
  method: 'put',
  data: param
})







